All Questions
17 questions
-1votes
1answer
172views
Efficient way to write test cases depending on a Micro service
I'm very new to microservice architecture. In the Monolithic app structure, it was pretty straightforward to write test cases since everything was in one app. I have a situation where I manage a ...
-1votes
1answer
572views
How to write tests for a class that talks to a server without revealing connection implementation
I'm writing a class that acts as the interface to a server. The interface exposes a way to send messages to the server and pass messages back to the client through a callback. Implementations should ...
2votes
3answers
1kviews
Still don't understand when to mock and when not to
I've been trying to understand when to mock and when not to mock, however I'm not able to come up with a consistent guideline and I'm hoping to get some input on the subject. Let's look at the ...
1vote
3answers
1kviews
Should I unit test functions internally used by API I expose?
I'm writing a CRUD app in Python that exposes web API. At first I wrote functions for communicating with DB and wrote tests for these functions. def crud(): # do something with db def test_crud(): ...
2votes
1answer
2kviews
Should I check floating point values in a unit test?
We have unit tests that are running some underlying model. We provide it with some test input, and receive some outputs + floating point scores. What's a good practice from a unit-testing standpoint? ...
-1votes
2answers
1kviews
How do you unit test methods with hard/impossible inputs to hardcode?
I have the following problem. I have a method which takes two other custom objects to work. This objects are required by the method because they have the information that the method requires to ...
-4votes
1answer
1kviews
Is it possible to derive a test suite to achieve 100% path coverage? [closed]
Here is an example with the function: Examining this I believe that it is possible to achieve 100% path coverage. My understanding of path coverage is that you need to design test cases such that ...
7votes
2answers
348views
Should examples for functions be unit tests?
I'm writing a python function to replace all the non-alphanumeric characters in the keys of this dictionary with underscores. To make sure it's working as expected as I don't have a ton of ...
2votes
1answer
456views
Best practices on testing a function based on third party service
I'm trying to figure out how to create unit tests for a function, which behavior is based on a third party service. Suppose a function like this: def sync_check(): delta_secs = 90 now = ...
1vote
1answer
579views
How to organize my test functions?
I'm writing a software application of a few thousand lines of code (in Python), and in order to keep the whole thing together, slowly but certainly the need for unit tests (and later, other types of ...
2votes
3answers
335views
Should I test the debug branch of my code in a unit test?
Lets say I have a function that gets a list of what files to send that are later send over a socket to some other pc. Now usually I keep track of what files have been sent and don't send these files ...
1vote
1answer
916views
Is there a cleaner way to test extras_require
I have code reviewed a piece of Python code, but to me it looks really ugly, hacky and complex for something that can be achieved very easily. The code looks something similar to the following: ...
3votes
1answer
2kviews
How to keep unit tests independent?
I've read it at many places that unit tests should be independent. In my case I have a class that does data transformation. These steps must be done sequentially, otherwise they don't make sense. For ...
9votes
4answers
7kviews
Behavior Driven Development and Unit Testing in Python [closed]
We might be interested in starting to incorporate a unit test suite to our project, which is coded in Python (and it uses Redis, PostgreSQL and some third-party libraries, if that bears into the ...
1vote
2answers
2kviews
How to populate a private container for unit test?
I have a class that defines a private (well, __container to be exact since it is python) container. I am using the information within said container as part of the logic of what the class does and ...